#include<iostream>
using namespace std;

struct ListNode {
     int val;
     ListNode *next;
     ListNode(int x) : val(x), next(NULL) {}
 };

 class Solution {
public:
    ListNode* deleteNode(ListNode* head, int val) {
        ListNode *dummy = new ListNode(-1);
        dummy->next = head;
        ListNode *pred  = dummy;
        ListNode *curr = pred->next;
        while (curr!=nullptr)
        {
            if(curr->val==val){
                pred->next = curr->next;
                break;
            }
            
            pred= curr;
            curr= curr->next;
        }
        
  return dummy->next;
    }
};